<template>
  <div class="base-table-box">
    <div class="table-select-group" v-if="!isAdvanced">
      <div class="left">
        <s-select
          :selectOption="year"
          v-model="params.strYear"
          style="width: 100px"
        />
        <a-tree-select
          style="width: 200px"
          :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
          :tree-data="treeData"
          tree-default-expand-all
          :treeIcon="true"
          :showSearch="true"
          v-model="topicTypeVal"
        >
        </a-tree-select>
        <s-select
          :selectOption="socialPublic.node"
          v-model="params.strPubNode"
          style="width: 100px"
        />
        <s-select
          :selectOption="socialPublic.selectType"
          v-model="params.strPubType"
          style="width: 100px"
        />
        <a-input
          class="search-input"
          v-model="params.search"
          placeholder="请输入搜索内容"
        />
        <a-button style="margin-left: 16px" type="primary" @click="start"
          >查询</a-button
        >
        <a-button @click="reset" class="btn-reset">重置</a-button>
        <a-button @click="toggle" style="margin-left: 16px" type="primary"
          ><i
            class="suncnui suncnui-icon-shaixuanchaxun"
            style="margin-right: 6px; font-size: 12px"
          ></i
          >高级查询</a-button
        >
      </div>
      <div class="right">
        <a-button type="primary" @click="goSupplement">补录</a-button>
      </div>
    </div>
    <div class="advanced-search-group" v-if="isAdvanced">
      <div class="advanced-name">
        <span>高级查询</span>
      </div>
      <a-form layout="inline" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row>
          <a-col :span="8">
            <a-form-item label="信息年份">
              <s-select :selectOption="year" v-model="params.strYear" />
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="主题类型">
              <a-tree-select
                :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                :tree-data="treeData"
                tree-default-expand-all
                :treeIcon="true"
                :showSearch="true"
                v-model="topicTypeVal"
              >
              </a-tree-select>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="是否采编">
              <a-select default-value="">
                <a-select-option value="">=是否采编= </a-select-option>
                <a-select-option value="0"> 是 </a-select-option>
                <a-select-option value="1"> 否 </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row style="margin-top: 10px">
          <a-col :span="8">
            <a-form-item label="信息状态">
              <a-select default-value="">
                <a-select-option value="">全部</a-select-option>
                <a-select-option value="0"> 信息标题 </a-select-option>
                <a-select-option value="1"> 信息来源</a-select-option>
                <a-select-option value="2"> 信息内容</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="是否联名">
              <a-radio-group v-model="isJointname">
                <a-radio :value="1"> 全部 </a-radio>
                <a-radio :value="2"> 否 </a-radio>
                <a-radio :value="3"> 是 </a-radio>
              </a-radio-group>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
      <div class="search-btn">
        <a-button style="margin-left: 16px" type="primary" @click="start"
          >查询</a-button
        >
        <a-button @click="reset" class="btn-reset">重置</a-button>
      </div>
      <div class="search-switch" @click="toggle">
        <i class="suncnui suncnui-icon-prev-1"></i>
      </div>
    </div>
    <a-table
      :pagination="pagination"
      :columns="columns"
      :data-source="tableData"
      :loading="loading"
      :scroll="{ y: '100%' }"
    >
      <div slot="action">
        <div class="tools">
          <span @click="jointName">联名信息</span>
        </div>
      </div>
      <div slot="state" slot-scope="text">
        {{ text }}
      </div>
      <template slot-scope="text, record, index" slot="listIndex">
        <span>{{ index + 1 }}</span>
      </template>
    </a-table>
    <backTrackedJointName
      :jointNameVisible="jointNameVisible"
      @closeFunc="jointNameVisible = false"
    ></backTrackedJointName>
  </div>
</template>
<script>
import paging from 'mixins/paging'
import deleteItem from 'mixins/delete-table-item.js'
import { socialPublic } from 'assets/js/select-option-list'
import backTrackedJointName from './backTrackedJointName'
const columns = [
  {
    title: '序号',
    scopedSlots: { customRender: 'listIndex' }
  },
  {
    title: '信息标题',
    dataIndex: 'title'
  },
  {
    title: '上报人',
    dataIndex: 'person'
  },
  {
    title: '上报类型',
    dataIndex: 'type',
    scopedSlots: { customRender: 'state' }
  },
  {
    title: '提交时间',
    dataIndex: 'time',
    sorter: (a, b) => a.name.length - b.name.length
  },
  {
    title: '状态',
    dataIndex: 'state'
  },
  {
    title: '是否采编',
    dataIndex: 'isAccept'
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]
export default {
  components: {
    backTrackedJointName
  },
  data() {
    return {
      jointNameVisible: false,
      topicTypeVal: '',
      treeData: [
        {
          title: '=主题类型=',
          value: '',
          key: '1'
        },
        {
          title: '文化建设',
          value: '文化建设',
          key: '2',
          children: [
            {
              value: '街道文化建设',
              key: '2-1',
              title: '街道文化建设'
            }
          ]
        },
        {
          title: '经济建设',
          value: '经济建设',
          key: '3'
        },
        {
          title: '政协建设',
          value: '政协建设',
          key: '4'
        }
      ],
      isAdvanced: false,
      isJointname: 1, //是否联名
      columns,
      socialPublic,
      params: {
        strYear: '2021',
        strPubType: 'all',
        strPubNode: 'all',
        search: ''
      },
      year: [
        { key: '2021', label: '2021' },
        { key: '2020', label: '2020' }
      ],
      labelCol: { span: 6 },
      wrapperCol: { span: 18 }
    }
  },
  mixins: [paging, deleteItem],
  methods: {
    jointName() {
      //联名弹框
      this.jointNameVisible = true
    },
    //补录跳转
    goSupplement() {
      this.$router.push(
        '/console/socialPublic/message/backTracked/infoSupplement'
      )
    },
    toggle() {
      this.isAdvanced = !this.isAdvanced
    },
    start() {
      console.log(this.form)
    },
    reset() {
      this.form = {}
    },
    add() {},
    deleteList(ids) {
      this.deleteItemMixins(() => {}, ids)
    },
    getTableData() {
      for (let i = 0; i < this.pagination.pageSize; i++) {
        this.tableData.push({
          key: i,
          title: `Edward King ${i}`,
          person: '张三',
          time: `20210303`,
          isAccept: '已采编',
          state: '待审核',
          type: Math.round(Math.random()) > 0.5 ? '专委会' : '政协委员'
        })
      }
      this.pagination.total = 200
    }
  }
}
</script>
<style lang="less" scoped>
.tools span:last-child {
  margin: 0 0 0 15px;
}
.tools span {
  color: #1c8de8;
  cursor: pointer;
  font-size: 16px;
}
.end {
  color: green;
}
.start {
  color: red;
}
.advanced-name {
  line-height: 34px;
  margin-bottom: 5px;
  font-size: 16px;
  color: #000000;
  font-weight: bold;
  span {
    height: 20px;
    line-height: 20px;
    /* border-left: 5px solid #0b78e7; */
    padding: 0px 10px;
    display: inline-block;
    vertical-align: middle;
    margin-top: -3px;
    margin-right: 5px;
  }
}
.advanced-search-group {
  padding: 15px 10px 5px 15px;
}
.search-btn {
  text-align: center;
  margin-top: 10px;
}
.advanced-search-group {
  padding-bottom: 40px;
  position: relative;
  background: #fff;
}
.search-switch {
  width: 36px;
  height: 36px;
  position: absolute;
  bottom: -10px;
  left: 50%;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  border-radius: 50%;
  margin-left: -18px;
  i {
    color: #4297ee;
    font-size: 20px;
    margin-top: 10px;
    display: inline-block;
    animation: arrow 0.7s linear infinite normal;
  }
}
@keyframes arrow {
  from {
    margin-top: 10px;
  }
  to {
    margin-top: 5px;
    opacity: 0;
  }
}
.ant-form-inline .ant-form-item {
  width: 100%;
}
</style>